import unittest
import sys
import os

sys.path += [os.path.abspath('..')]

from utils import thumbnailer

class ThumbnailerTest(unittest.TestCase):

    def setUp(self):
        self.debug = False

    def testValidThumbnailType(self):
        thumbnailer_image = thumbnailer.Thumbnailer(os.path.abspath('.') + '/data/ImageThumbnailer/test.jpg', 'image')
        self.assertTrue(isinstance(thumbnailer_image, thumbnailer.Thumbnailer))

        thumbnailer_video = thumbnailer.Thumbnailer(os.path.abspath('.') + '/data/VideoThumbnailer/test.avi', 'video')
        self.assertTrue(isinstance(thumbnailer_video, thumbnailer.Thumbnailer))
        
        thumbnailer_recording = thumbnailer.Thumbnailer(os.path.abspath('.') + '/data/VideoThumbnailer/test.avi', 'recording')
        self.assertTrue(isinstance(thumbnailer_recording, thumbnailer.Thumbnailer))
        
    def testInvalidThumbnailType(self):
        self.assertRaises(thumbnailer.ThumbnailerException, thumbnailer.Thumbnailer, os.path.abspath('.') + '/data/ImageoThumbnailer/test.jpg', 'alskdjfhg')


    def testValidFileToThumbnail(self):
        thumbnailer_image = thumbnailer.Thumbnailer(os.path.abspath('.') + '/data/ImageThumbnailer/test.jpg', 'image')
        self.assertTrue(isinstance(thumbnailer_image, thumbnailer.Thumbnailer))
    
    def testInvalidFileToThumbnail(self):
        self.assertRaises(thumbnailer.ThumbnailerException, thumbnailer.Thumbnailer, os.path.abspath('.') + '/data/ImageThumbnailer/alskdjfhg.jpg', 'image')

    def testAbstractCreateThumbnailer(self):
        thumbnailer_test = thumbnailer.Thumbnailer(os.path.abspath('.') + '/data/ImageThumbnailer/test.jpg', 'image')
        self.assertRaises(NameError, thumbnailer_test.create_thumbnail)